#include <iostream>
using namespace std;
const int N = 110;
char a[N][N], b[N][N];
int n, m;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1,};
int slove(int x, int y) {
    int cnt = 0;
    for(int i = 0; i < 8; i++) {
        int A = x + dx[i], B = y + dy[i];
        if(A >= 0 && B >= 0 && A < n && B < m && a[A][B] == '*') {
            cnt++;
        }
    }
    return cnt;
}
int main() {
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            char c;
            cin >> c;
            a[i][j] = b[i][j] = c;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(a[i][j] == '?') {
                b[i][j] = slove(i, j) + '0';
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cout << b[i][j];
        }
        cout << endl;
    }
    return 0;
}